{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ac91e114",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "from pyecharts.charts import Bar\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9c3af972",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\zhang\\\\Documents\\\\GitHub\\\\vnpy\\\\examples\\\\jupeter\\\\timeline_bar_with_graphic.html'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Bar, Timeline\n",
    "from pyecharts.commons.utils import JsCode\n",
    "from pyecharts.faker import Faker\n",
    "\n",
    "x = Faker.choose()\n",
    "tl = Timeline()\n",
    "for i in range(2015, 2020):\n",
    "    bar = (\n",
    "        Bar()\n",
    "        .add_xaxis(x)\n",
    "        .add_yaxis(\"\", Faker.values())\n",
    "        .reversal_axis()\n",
    "        .set_global_opts(\n",
    "            title_opts=opts.TitleOpts(\"\".format(i)),\n",
    "            graphic_opts=[\n",
    "                opts.GraphicGroup(\n",
    "                    graphic_item=opts.GraphicItem(\n",
    "                        rotation=JsCode(\"Math.PI / 4\"),\n",
    "                        bounding=\"raw\",\n",
    "                        right=100,\n",
    "                        bottom=110,\n",
    "                        z=100,\n",
    "                    ),\n",
    "                    children=[\n",
    "                        opts.GraphicRect(\n",
    "                            graphic_item=opts.GraphicItem(\n",
    "                                left=\"center\", top=\"center\", z=100\n",
    "                            ),\n",
    "                            graphic_shape_opts=opts.GraphicShapeOpts(\n",
    "                                width=400, height=50\n",
    "                            ),\n",
    "                            graphic_basicstyle_opts=opts.GraphicBasicStyleOpts(\n",
    "                                fill=\"rgba(0,0,0,0.3)\"\n",
    "                            ),\n",
    "                        ),\n",
    "                        opts.GraphicText(\n",
    "                            graphic_item=opts.GraphicItem(\n",
    "                                left=\"center\", top=\"center\", z=100\n",
    "                            ),\n",
    "                            graphic_textstyle_opts=opts.GraphicTextStyleOpts(\n",
    "                                text=\"某国{}年营业额\".format(i),\n",
    "                                font=\"bold 26px Microsoft YaHei\",\n",
    "                                graphic_basicstyle_opts=opts.GraphicBasicStyleOpts(\n",
    "                                    fill=\"#fff\"\n",
    "                                ),\n",
    "                            ),\n",
    "                        ),\n",
    "                    ],\n",
    "                )\n",
    "            ],\n",
    "        )\n",
    "    )\n",
    "    tl.add(bar, \"{}年\".format(i))\n",
    "tl.render(\"timeline_bar_with_graphic.html\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ed41b657",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0b8578e9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
